import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String origin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; //映射前字符串
        String number = "222333444555666777788899991234567890"; //映射后字符串
        while(sc.hasNext()){
            int n = sc.nextInt();
            //创建一个ArrayList对象
            ArrayList<String> list = new ArrayList<String>();
            for(int i = 0; i < n; i++){
                String str = sc.next();
                str = str.replace("-","");
                String result = "";
                for(int j = 0; j < 7; j++){
                    //indexOf方法返回子字符串在origin中第一次出现的索引
                    result += number.charAt(origin.indexOf(str.charAt(j)+""));
                }
                //拼接成电话号码的形式
                result = result.substring(0,3)+"-"+result.substring(3,7);
                //判断list是否已经包含该电话号码，也就是去重
                if(!list.contains(result)){
                    list.add(result);
                }
            }
            //对所有电话号码排序
            Collections.sort(list);
            for(int j = 0; j < list.size(); j++){
                System.out.println(list.get(j));
            }
            System.out.println();
        }
        sc.close(); //关闭Scanner
    }
}